import requests, re


def main(url):
    response = requests.get(url)
    html = response.text
    aa = re.findall('data-title="(.*?)"', html, re.S)
    num = 1
    bb = re.findall('data-score="(.*?)"', html, re.S)
    cc = re.findall('data-release="(.*?)"', html, re.S)
    dd = re.findall('data-region="(.*?)"', html, re.S)
    with open('./2-28-1.txt', 'a', encoding='utf-8') as f:
        for a, b, c, d in zip(aa, bb, cc, dd):
            print('---' + str(num) + '---')
            print('电影名称: ' + a)
            print('评分:' + b)
            print('上映年份: ' + c)
            print('上映国家:' + d)
            num += 1
            print()
            f.write('电影名称: ' + a + '\n')
            f.write('评分:' + b + '\n')
            f.write('上映年份: ' + c + '\n')
            f.write('上映国家:' + d + '\n')
            f.write('\n')


if __name__ == '__main__':
    url = 'https://movie.douban.com/cinema/nowplaying/wuhan/'
    main(url)
